package events
{
	import flash.events.Event;
	import flash.events.EventDispatcher;

	public class GameEventExcuter extends EventDispatcher
	{
		
		private var handlers:Object = new Object;
		
		public function GameEventExcuter()
		{
			
		}
		
		public function addHandler(eventType:String,handler:Function):void
		{
			this.addEventListener(eventType,executer);
			handlers[eventType] = handler;
		}
		
		public function executer(event:Event):void
		{
			var func:Function = handlers[event.type] as Function;
			if(event is GameEvent)
			{
				var info:Object = (event as GameEvent).m_info;
				if(func != null)
					func(info);
			}
			else
			{
				if(func != null)
					func();
			}
		}
		
		public function removeHandler(eventType:String):void
		{
			this.removeEventListener(eventType,executer);
			handlers[eventType] = null;
		}
		
	}
}